function SelectRightALL(){

	var optionRightLen=document.form.RightList.options.length;

	for (var i=optionRightLen-1;i>=0;--i){
		document.form.RightList.options[i].selected = true
	}
}

function AddToRight(){
	   for (i=0 ; i<=form.LeftList .options .length -1 ; i++)
		  {
			if (form.LeftList.options[i].selected)
			  {
				var addOption = new Option(); 
				addOption.text = document.form.LeftList.options[i].text;
				addOption.value = document.form.LeftList.options[i].value;
				form.RightList.options.add(addOption);
			  }  
			  
		  }  
	   
	   //删除选定记录 
	   for (i=0 ; i< form.LeftList .options .length ; i++)
		  {
			if (form.LeftList .options [i].selected)
			  {
				form.LeftList.remove(i);
				i = i - 1 ;
			  }  
			  
		  }  

}

function DelFromRight(){
	   for (i=0 ; i<=form.RightList .options .length -1 ; i++)
		  {
			if (form.RightList .options [i].selected)
			  {
				var addOption = new Option(); 
				addOption.text = document.form.RightList.options[i].text;
				addOption.value = document.form.RightList.options[i].value;
				form.LeftList.options.add(addOption);

			  }  
			  
		  }  
	   
	   //删除选定记录 
	   for (i=0 ; i< form.RightList .options .length ; i++)
		  {
			if (form.RightList .options [i].selected)
			  {
				form.RightList.remove(i);
				i = i - 1 ;
			  }  
			  
		  }  
}

function checkform() 
{
	SelectRightALL();
	var s=document.form.RightList.value;
	if (s.length==0) {
		alert( "提醒：至少应选择一项! ");
		return false;
	}
	else return true; 
}

function changepos(obj,index)
{
	if(index==-1){
		if (obj.selectedIndex>0){
			obj.options(obj.selectedIndex).swapNode(obj.options(obj.selectedIndex-1))
		}
	}
	else if(index==1){
		if (obj.selectedIndex<obj.options.length-1)	{
			obj.options(obj.selectedIndex).swapNode(obj.options(obj.selectedIndex+1))
		}
	}
}

//=======
//2008-9-25
function checkall()
{
	  var sall = document.getElementById("Select_All").checked;
	  var select_id = document.getElementsByName("Op_ID");
	  if (select_id.length)
	  {
		slength = select_id.length;
		for (var i = 0; i < slength; i++) { select_id[i].checked = sall; }
	  }
	  else { select_id.checked = sall; }
}
function batch_del(){
	var groups = document.getElementsByName("Op_ID");
	var hasChecked = 0;
	for(var i=0; i<groups.length;i++)
	if(groups[i].checked) hasChecked++;
	if(hasChecked==0)
	{
		alert("请选择要删除的记录!");
		return false;
	}
	if (confirm('是否真的要删除这些信息？')) {
		try
		{
		document.form.action=document.getElementById("del_action").value;
		document.form.submit();
		}
		catch(e)
		{
		alert("出错了");
		}
	}
	else return false;
}

function Set_Sort(){
	var groups = document.getElementsByName("Op_ID");
	var hasChecked = 0;
	for(var i=0; i<groups.length;i++)
	if(groups[i].checked) hasChecked++;

	if(hasChecked==0)
	{
		alert("请选择要置顶的信息!");
		return false;
	}

	if (confirm('是否真的要置顶这些信息？')) {
		try
		{
			document.form.action=document.getElementById("Sort_Action").value;
			document.form.submit();
		}
		catch(e)
		{
			alert("设置错误");
		}
	}
	else return false;
}

function Del()
{
   var del_id;
   del_id=""
   for (i=0 ; i<=form.LeftList .options .length -1 ; i++)
	  {
		if (form.LeftList.options[i].selected)
		  {
			del_id = del_id +","+ document.form.LeftList.options[i].value;
		  }  
		  
	  }  
	if (del_id=="")
	{
		return false;
	}
	$.post(
	"/2010admin/common/Ajax_Del_Sort_Table.asp",
	{
	id: del_id
	},
	function (r_value) {

		if (r_value=="1")
		{
		   //删除选定记录 
		   for (i=0 ; i< form.LeftList .options .length ; i++)
			  {
				if (form.LeftList .options [i].selected)
				  {
					form.LeftList.remove(i);
					i = i - 1 ;
				  }  
				  
			  }  

			alert("删除成功!");

		}
		else
		{
			alert("出错了!");
		}

	}
	);
}